import java.io.*;
import java.util.Timer;

public class FileCopy {
    public static void main(String[] args) {
        try {
            FileInputStream inputStream = new FileInputStream("video.mp4");
            FileOutputStream outputStream = new FileOutputStream("video-copy1.mp4");

            long start = System.currentTimeMillis();

            // int c;
            // while ((c = inputStream.read()) != -1) {
            //     outputStream.write(c);
            // }

            // byte[] temp = new byte[64];
            // int length;
            // while ((length = inputStream.read(temp)) != -1) {
            //     outputStream.write(temp,0,length);
            // }

            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);

            int length;
            byte[] temp = new byte[8192];
            while ((length = bufferedInputStream.read(temp)) != -1) {
                bufferedOutputStream.write(temp, 0, length);
            }

            long end = System.currentTimeMillis();

            outputStream.close();
            inputStream.close();

            System.out.println(end - start);

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
